<?php
class TranSactionlog extends Controller {
	function TranSactionlog() {
		parent::Controller();
		$this->load->helper("url");
		$this->data["base"] = $this->config->item('base_url');
		$this->load->model('TransLog');
		$this->load->database();	
                session_start();
	}
	function index() {
		if(isset($_SESSION['sys_admin']) and isset($_SESSION['name'])) {
			$this->formTransaction();
		} else {
			
			$this->load->vars($this->data);
			$this->load->view('layout/head');
			$this->load->view('layout/body');
			$this->load->view('content');
			$this->load->view('layout/foot');
		}
	}
	function formTransaction() {
		$this->data['h2_title'] = 'Transaction Log';
		$id = $_SESSION['name'];
		$a = $this->TransLog->show_user_log($id)->row();
		$user_id = $a->name;
		$translog = $this->TransLog->show_all_translog($user_id)->result();
		
		//set template table untuk efek selang-sling tiap bariS
			$tmpl = array('table_open' =>'<table border="0" cellpadding="0" cellspacing="0">','row_alt_start' =>'<tr class="zebra">','row_alt_end' =>'</tr>');
		$this->table->set_template($tmpl);
		$this->table->set_empty("&nbsp;");
		$this->table->set_heading('No','Name','Notes','Date Time','IP');
		
		$i =0;
		foreach($translog as $log) {
			$this->table->add_row(++$i,$log->name,$log->notes,$log->datetime,$log->ip);
		}
		$this->data['table'] = $this->table->generate();
		
		$this->load->vars($this->data);
		$this->load->view('layout/head');
		$this->load->view('layout/body');
		$this->load->view('layout/search');
		$this->load->view('sysadmin/transLog');
		$this->load->view('layout/foot');
	}
}
?>